/* eslint-disable @iceworks/best-practices/recommend-polyfill */
import { Drawer } from '@alifd/next';
import React from 'react';
import { useParams } from 'react-router';
import BusOrderRefund from '../account/Refund/components/BusOrderRefund';
import ScOrderRefund from '../account/Refund/components/ScOrderRefund';
import CcOrderRefund from '../account/Refund/components/CcOrderRefund';
import RsOrderRefund from '../account/Refund/components/RsOrderRefund';

export default function RefundView() {
  const { id, refundApplyId } = useParams();
  /**
   * 订单类型： 1 - 包车； 2 - 专线； 3 - 巴士
   */
  let orderType = 1;
  if (id?.startsWith('SCO')) orderType = 2;
  if (id?.startsWith('BUS')) orderType = 3;
  if (id?.startsWith('RS')) orderType = 4;

  const handleClose = () => {
    window.parent.postMessage('closed', '*');
  };

  return (
    <div style={{}}>
      <Drawer
        closeMode={[]}
        visible
        animation={false}
        width="100%"
        style={{ maxWidth: '100%', border: 0 }}
        onClose={handleClose}
      >
        {orderType === 1 &&
          <CcOrderRefund
            refundId={refundApplyId}
            isView={['view']}
            modal={['view']}
            onCancel={() => handleClose()}
          />}
        {orderType === 2 &&
          <ScOrderRefund
            refundId={refundApplyId}
            isView={['view']}
            modal={['view']}
            onCancel={() => handleClose()}
          />}
        {orderType === 3 &&
          <BusOrderRefund
            refundId={refundApplyId}
            isView={['view']}
            modal={['view']}
            onCancel={() => handleClose()}
          />}
        {orderType === 4 &&
          <RsOrderRefund
            refundId={refundApplyId}
            isView={['view']}
            modal={['view']}
            onCancel={() => handleClose()}
          />}
      </Drawer>

    </div>
  );
}
